<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        const p=new Promise((resolve,reject)=>{
            setTimeout(function(){
                //设置p对象的状态，并且设置失败的值
                reject("出错了");
            },1000)
        });

        //then方法
        /*
        p.then(function(value){
            console.log("成功了");
        },function(reason){
            console.error("出错了");
        })
        */
        
        //catch()方法
        p.catch(function (reason){
            console.warn(reason);
        });
    </script>
</head>
<body>
    
</body>
</html>